package com.example.drawboard.view.draw;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;

public class DrawShapUtils {
    public static void drawPentagon(Canvas canvas, int left,int top, int width, int height, Paint paint){

        int bottom_ofset = (width -(int) (width/(2*Math.cos(Math.toRadians(36)))))/2;

        Path path = new Path();
        path.moveTo(width/2 + left,top); // 第一个点
        path.lineTo(left,top +(int)((Math.tan(Math.toRadians(36)) * height)/4)  );

        path.lineTo(left + bottom_ofset,top + height);
        path.lineTo(left + width - bottom_ofset,top + height);
        path.lineTo(left +width,top +(int)((Math.tan(Math.toRadians(36)) * height)/4)  );
        path.close();
        canvas.drawPath(path,paint);
    }
}
